﻿using JzSport.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JzSport.Api
{
    class RejectFriendsRequestAction : AuthPostAction<Params.RejectFriendsRequestParams,
        Results.RejectFriendsRequestResult>
    {
        protected override ActionResult<Results.RejectFriendsRequestResult> OnExecute(ActionContext context, 
            SysParameters sysParameters,
            Params.RejectFriendsRequestParams opParams)
        {
            ServiceResult<UserRelation> serviceResult = new FriendsService().RejectRequest(context.AccountId,
                opParams.TargetUserId);

            Results.RejectFriendsRequestResult actionResult = new Results.RejectFriendsRequestResult();

            if (serviceResult.ErrorCode == ErrorCode.NoError)
            {
                return new ActionResult<Results.RejectFriendsRequestResult>(true, serviceResult.ErrorCode,
                    ErrorCode.ToString(serviceResult.ErrorCode), actionResult);
            }
            return new ActionResult<Results.RejectFriendsRequestResult>(false, serviceResult.ErrorCode,
                    ErrorCode.ToString(serviceResult.ErrorCode), actionResult);
        }
    }
}
